<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Personal extends Model
{

    public $timestamps = false;
    protected $connection = 'xz';
    protected $table = 'personal';
    use HasFactory;

    protected $hidden = [
        'passwd',
    ];

    public function org()
    {
        return $this->hasOne('App\Models\Enterprise','id','es_id')->select('id','name','full_name','tell');
    }

    public function department()
    {
        return $this->hasOne('App\Models\CompanyDepartment','id','department_id');
    }

    public function studys()
    {
        return $this->hasOne('App\Models\StudyLog','uid','id')->select('id','course_id','uid','video_id','task_id');
    }

    public function studyTimeSum()
    {
        return $this->hasMany('App\Models\StudyUserTime','uid','id')->sum('study_length');
    }

    public function studyTimes()
    {
        return $this->hasMany('App\Models\StudyUserTime','uid','id');
    }

}
